package com.yiren.backstage.judge.thread;

import android.content.Context;

import com.yiren.backstage.currency.constant.AutoJudgeConstant;
import com.yiren.backstage.currency.entity.ProjectEntity;
import com.yiren.backstage.currency.enums.TaskStateEnum;
import com.yiren.backstage.currency.utils.MessageUtil;
import com.yiren.backstage.judge.handler.LightJudgeHandler;
import com.yiren.backstage.judge.services.light.ILightStartTipsService;
import com.yiren.backstage.judge.services.light.impl.LightStartTipsServiceImpl;
/**
 * Time:2022/3/23 19:29
 * Author:xiaozan
 * Description:灯光操作前提示线程
 */
public class LightTipsThread implements Runnable{

    private LightJudgeHandler lightJudgeHandler;

    private ILightStartTipsService iLightStartTipsService;

    private ProjectEntity projectEntity;

    public LightTipsThread(Context context, LightJudgeHandler lightJudgeHandler,ProjectEntity projectEntity){
        this.lightJudgeHandler = lightJudgeHandler;
        iLightStartTipsService = new LightStartTipsServiceImpl(context,lightJudgeHandler);
        this.projectEntity = projectEntity;
    }

    @Override
    public void run() {
        while (lightJudgeHandler.getTaskStateEnum() != TaskStateEnum.FORCT_CLOSE){
            //提示是否提示发动机
            boolean startTips = iLightStartTipsService.tipsPlayStartEngine();

            //提示是否关闭所有灯光
            if(!startTips){
                boolean closeLightTips = iLightStartTipsService.tipsPlayCloseLight();
                if(!closeLightTips){
                    //启动灯光评判
                    lightJudgeHandler.sendMessage(MessageUtil.newMessage(AutoJudgeConstant.START_UP_LIGHT_JUDGE, projectEntity));
                    return;
                }
            }

        }
    }
}
